//
//  NSString+Extension.h
//  customer
//
//  Created by Holothurian on 2018/10/19.
//  Copyright © 2018年 yinlong. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSString (Extension)
#pragma mark - -------- delete ----------

/// 删除字符 删除开头和结尾空格
- (NSString *)deleteTriSpace;

/// 删除字符 删除空格
- (NSString *)deleteSpace;

- (NSString *)delete_nbsp;

/// 删除字符 删除空格和换行
- (NSString *)deleteSpaceAndLine;

/// 删除字符 删除标点符号
- (NSString *)deleteSpecialChar;

/// 删除指定字符串 regex:正则表达式
- (NSString *)deleteByRegex:(NSString *)regex;

/// 删除指定字符串 target:指定字符串
- (NSString *)deleteStr:(NSString *)target;

/// 删除不匹配的字符串 target:指定字符串
- (NSString *)deleteUnMatchStr:(NSString *)target;

#pragma mark - -------- new string by sub ----------

/// 截取字符串 指定结尾下标
- (NSString *)subTo:(NSUInteger)to;

/// 截取字符串 指定开始下标
- (NSString *)subFrom:(NSUInteger)from;

/// 截取字符串 截取为日期 (yyyy-MM-dd )
- (NSString *)subToDate;

/// 截取字符串 截取为数组
- (NSArray *)subToArrBy:(NSString *)sub;

#pragma mark - -------- new string by init ----------

/// int 初始化字符串
+ (NSString *)stringByInt:(int)t;

/// float 初始化字符串
+ (NSString *)stringByFloat:(float)f;

/// id 初始化字符串
+ (NSString *)stringById:(id)param;

/// 字符串 转 number
- (NSNumber *)numberValue;

/// 拼接字符串 追加字符串
- (NSString *)appendFmt:(NSString *)format, ...;

/// 拼接字符串 追加字符串
- (NSString *)appendStr:(NSString *)str;

/// 拼接字符串 追加路径
- (NSString *)appendPath:(NSString *)str;

/// 获取指定位置的 字符
- (NSString *)strAtIndex:(NSInteger)index;

/// 生成uuid
+ (NSString *)uuidWithPrefix:(NSString *)prefix;

/// URL 标准转码
- (NSString *)encodeURL;

#pragma mark - -------- is xxx string ----------

/// 是否有效的日期字符串
- (BOOL)isValidDate;

/// 是否包含特殊字符
- (BOOL)isContainSpecialChar;

/// 是否包含数字
- (BOOL)isContainNumber;

/// 是否纯数字
- (BOOL)isNumber;

/// 判断是否为整形：
- (BOOL)isPureInt;

/// 判断是否为浮点形：
- (BOOL)isPureFloat;

/// 是否包含指定字符串
- (BOOL)isContain:(NSString *)str;

/// 是否包含指定字符串 regex:正则表达式
- (BOOL)isByRegex:(NSString *)regex;

/// 是否有效手机号码 [大陆手机]
- (BOOL)isMobileNumber;

/// 加密手机号码
-(NSString*)encryMobile;

#pragma mark - RandomKey
+ (NSString *)randomKey;

- (NSString *)MD5;

@end

#pragma mark - -------- NSMutableString ----------

@interface NSMutableString (add)

/// 拼接字符串 追加字符串
- (void)addStr:(NSString *)str;
/// 拼接字符串 追加CDATA字符串
- (void)addCDATA:(NSString *)str;

@end

#define s_Null_Date     @"1970-01-01"
#define ALPHA           @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz "
#define NUMBERS         @"0123456789"
#define ALPHANUM        @"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
#define NUMBERSPERIOD   @"0123456789."

NS_ASSUME_NONNULL_END
